package com.citywy.client;

import com.citywy.service.AccountService;
import com.citywy.service.impl.AccountServiceImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 模拟表现层，调用业务层
 */
public class Client {
    public static void main(String[] args) {
        //1.获取核心容器对象
        ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
        //2.根据ID获取Bean对象
//        AccountService as = (AccountService) context.getBean("accountService");
//        as.saveAccount();

        //set注入
//        AccountService as = (AccountService) context.getBean("accountService2");
//        as.saveAccount();

        //复杂类型注入
        AccountService as = (AccountService) context.getBean("accountService3");
        as.saveAccount();
    }
}
